/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package earthdawnnet.util;

import java.util.Collection;
import java.util.Observable;
import java.util.Observer;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 *
 * @author Andreas Franek
 */
public class Chat extends Observable
{
    ConcurrentLinkedQueue<String> chat = new ConcurrentLinkedQueue<String>();
    
    public Collection<String> getChatLines()
    {
        return chat;
    }

    public void add(String s)
    {
        chat.add(s);
        setChanged();
        notifyObservers(chat);
    }

    public void addAll(Collection<? extends String> c)
    {
        chat.addAll(c);
        setChanged();
        notifyObservers(chat);
    }

    @Override
    public void addObserver(Observer o)
    {
        super.addObserver(o);
        o.update(this, chat);
    }
}
